const mysql = require('mysql');
const pool  = mysql.createPool({
	// connectionLimit : 10,
	host            : 'localhost',
	user            : 'root',
	password        : 'root',
	database        : 'nodecms'
})

exports.query = async (strSql) => {
	return new Promise((resolve, reject) => {
		pool.getConnection((err, connection) => {
			if (err) {
				return reject(err)
			}
			connection.query(strSql, (err, ...args) => {
				connection.release()
				if (err) {
					return reject(err)
				}
				resolve(...args)
			})
		})
	})
}